Python Essentials 1 by The OpenEDG Python Institute

Python Essentials 1 by The OpenEDG Python Institute
Author: The OpenEDG Python Institute
Language: eng
Format: epub
Published: 2022-12-14

3.3.3 Logical values vs. single bits


Logical operators take their arguments as a whole regardless of how many bits they contain. The operators are aware only of the value: zero (when all the bits are reset) means False; not zero (when at least one bit is set) means True.

The result of their operations is one of these values: False or True. This means that this snippet will assign the value True to the j variable if i is not zero; otherwise, it will be False.

i = 1

j = not not i

3.3.4 Bitwise operators